LITEOSTOPDIR ?= ../..

SAMPLE_OUT = .

include $(LITEOSTOPDIR)/config.mk

LITEOS_LIBDEPS := --start-group $(LITEOS_LIBDEP) --end-group
LITEOS_CFLAGS += -Wall -I ./include 
LITEOS_LDFLAGS += -L./lib -lhi_osal -uosal_proc_init -umedia_mem_init
LITEOS_LDFLAGS += -L./lib -lhi3516ev200_base -ubase_get_module_param -ubase_mod_init

SRCS := $(wildcard *.c)

OBJS := $(patsubst %.c,$(SAMPLE_OUT)/%.o,$(SRCS))

all: $(OBJS)
ifneq ($(OUT)/lib/libipcm.a, $(wildcard $(OUT)/lib/libipcm.a))
	echo "$(OUT)"
	cp -rf $(LITEOS_CPU_TYPE)/*.a $(OUT)/lib
endif
	$(LD) $(LITEOS_LDFLAGS) --gc-sections -Map=$(SAMPLE_OUT)/sample.map -o $(SAMPLE_OUT)/sample $(OBJS) $(LITEOS_LIBDEPS) $(LITEOS_TABLES_LDFLAGS)
	$(OBJCOPY) -O binary $(SAMPLE_OUT)/sample $(SAMPLE_OUT)/sample.bin
	$(OBJDUMP) -d $(SAMPLE_OUT)/sample >$(SAMPLE_OUT)/sample.asm

clean:
	@$(RM) *.o  sample *.bin *.map *.asm

$(OBJS): $(SAMPLE_OUT)/%.o : %.c
	$(CC) $(LITEOS_CFLAGS) -c $< -o $@

